<%@page import="com.award.model.Advertising"%>
<%@page import="com.award.model.Commodity"%>
<%@page import="com.award.jdbc.dao.JdbcDao"%>
<%@page import="com.award.model.User"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
JdbcDao jd= new JdbcDao();
List<Advertising> advertising_list=jd.queryAllAdvertising();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>首页</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link type="text/css" href="./css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link type="text/css" href="./css/flat-ui.min.css" rel="stylesheet">
    <link type="text/css" href="./css/style.min.css" rel="stylesheet">
  </head>
  
 <body>
<jsp:include page="jsp/border/header.jsp" flush="true"/>
<div class="container">
<!-- 一堆酒瓶子 -->
    <div id="banner">
        <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
            <% for(int i=0;i<advertising_list.size();i++){ %>
            <%if(0==i){ %>
            <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
            <%}else{ %>
            <li data-target="#carousel-example-generic" data-slide-to="<%= i %>"></li>
            <%} %>
            <%} %>
            </ol>
           <div class="carousel-inner" role="listbox">
                 <% 
                 Advertising ad = null;
                 for(int i=0;i<advertising_list.size();i++){ 
                 ad=advertising_list.get(i);
                 %>
                 <% if(0==i){ %>
            <div class="item active">
                    <img src="<%= ad.getImgUrl() %>" alt="...">
                    <div class="carousel-caption">
                        ...
                    </div>
                </div>
                <%}else{ %>
                <div class="item">
                    <img src="<%= ad.getImgUrl() %>" alt="...">
                    <div class="carousel-caption">
                        ...
                    </div>
                </div>
                <%} %>
            <%} %>
            </div>

            <!-- Controls -->
            <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
            </a>
            <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>
    </div>
    <!-- 标题 -->
    <div class="title-page">
        <h1>Raffles</h1>
    </div>
    <!-- 物品列表 -->
    <% 
    List<Commodity> commodity_list=jd.queryAllCommodity();
    for(Commodity c:commodity_list){
    if(c.getOpenTime().getTime()<new Date().getTime()&&-1==c.getAward()){
    jd.openTimeComming(c.getId());
    c.setAward(0);
    }
    }
     %>
    <div id="items-list">
        <div class="row">
        <%  for(Commodity c:commodity_list){ %>
        <% if(0==c.getAward()) {%>
            <div class="col-md-3 col-sm-6">
                <div class="item">
                    <div class="item-header">
                       <span class="item-name"><%= c.getCommodityName() %></span>
                        <span style="font-size: 10px;color: #000c0e"> 正在进行中</span>
                        <span class="item-state"></span>
                        <span class="item-image" style="background-image: url('<%= c.getImgURL() %>');"><br/></span>
                        <span class="item-state"></span>
                        <span class="item-sugprice">价格</span>
                        <span class="item-price">￥<%= c.getPrice() %></span>
                    </div>
                    <div class="item-footer">
                    <span class="item-slots"><i class="fui-user"></i><%= c.getSelectPeopleNum() %> / <%= c.getTotal()%></span><br>
                        <a class="sbtn sbtn-red" href="./jsp/raffle.jsp?CommodityID=<%= c.getId() %>">进入</a>
                    </div>
                </div>
            </div>
            <%} %>
            <%} %>
        </div>
    </div>
</div>
<footer>
    <div>
        Copyright &copy; 2017
    </div>
</footer>

<script src="./js/jquery.min.js"></script>
<script src="./js/flat-ui.min.js"></script>
<script>
	$('.nav-item-index').addClass("active");
</script>
</body>
  
</html>
